
# 组合方式完成授权；授权所以跟新的功能用自己的类里面的、
# 没有更新的交给继承的类处理
# coding=utf-8
# sample one
import time
class FileHandle:
    def __init__(self,filename,mode='r',encoding="utf-8"):
        # self.filename=filename
        self.file = open(filename,mode,encoding=encoding)
        self.mode = mode
        self.encoding =encoding
    def write(self,line):
        now =time.strftime("%Y-%m-%d %X")
        print(" %s %s"%(now,line))
        self.file.write(" %s %s"%(now,line))
    def __getattr__(self, item):
        print(item,type(item))
        return getattr(self.file,item)
f1= FileHandle("object.txt","w+")
print(f1.__doc__)
print("read",f1.read)
print(f1.write)
f1.seek(0)
f1.write("111111111\n")
f1.write("内存空间不足\n")
f1.write("cpu空间不足\n")
f1.write("磁盘空间不足\n")
f1.write("CPU温度过高\n")
print("----------------")
f1.seek(0)
print(f1.read())
